﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModelWorker.aspx.cs" Inherits="GH.Web.UionReport.ModelWorker" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>欢迎使用工会管理系统</title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            font-size: 16px;
            font-weight: bold;
        }
    </style>
    <style type='text/css'>
        thead
        {
            font-size: 12pt;
            font-weight: bold;
            color: #444;
        }
        tbody
        {
            font-size: 10pt;
            color: #444;
        }
        td, th
        {
            border: solid 1px #E6E6E6;
            padding-left: 3px;
        }
        th
        {
            background-color: #5B8;
        }
        .alternation
        {
            background-color: #D2FFD2;
        }
        .alternation3
        {
            background-color: #DDEEDD;
        }
        .selected
        {
            background-color: #B3E1A3;
        }
    </style>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../css/css.css" />
    <link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css" />
    <link rel="stylesheet" type="text/css" href="../JqueryUI/themes/ui-lightness/jquery-ui-1.7.2.custom.css">

    <script type="text/javascript" src="../javascript/jquery-1.3.2.js"></script>

    <script type="text/javascript" src="../javascript/jquery-ui-1.7.2.custom.js"></script>

    <script type="text/javascript" src="../javascript/formValidator.js"></script>

    <script type="text/javascript" src="../javascript/formValidatorRegex.js"></script>

    <script type="text/javascript" src="../javascript/Public.js"></script>

    <link rel="stylesheet" type="text/css" href="../css/calendar.css" />

    <script type="text/javascript" src="../javascript/jquery-calendar.js"></script>

    <script type="text/javascript" src="../javascript/cal.js"></script>

    <!-- BEGIN  Select带可输入的功能  BEGIN -->

    <script type='text/javascript'>
        //定义 select 原值
        var oldValue, oldText;
        //select下拉框的onkeydown事件，修改下拉框的值
        function catch_keydown(sel) {
            switch (event.keyCode) {
                case 13: //回车键
                    event.returnValue = false;
                    break;
                case 27: //Esc键
                    sel.options[sel.selectedIndex].text = oldText;
                    sel.options[sel.selectedIndex].value = oldValue;
                    event.returnValue = false;
                    break;
                case 8:  //空格健
                    var s = sel.options[sel.selectedIndex].text;
                    s = s.substr(0, s.length - 1);
                    if (sel.options[0].value == sel.options[sel.selectedIndex].text) {
                        sel.options[sel.selectedIndex].value = s;
                        sel.options[sel.selectedIndex].text = s;
                    }
                    event.returnValue = false;
                    break;
            }
            if (!event.returnValue && sel.onchange)
                sel.onchange(sel)
        }

        //select下拉框的onkeypress事件，修改下拉框的值
        function catch_press(sel) {
            if (sel.selectedIndex == 0) {
                var s = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
                sel.options[sel.selectedIndex].value = s;
                sel.options[sel.selectedIndex].text = s;
                event.returnValue = false;
                if (!event.returnValue && sel.onchange)
                    sel.onchange(sel)
            }
        }

        //select下拉框的onfocus事件，保存下拉框原来的值
        function catch_focus(sel) {
            oldText = sel.options[sel.selectedIndex].value;
            oldValue = sel.options[sel.selectedIndex].value;
        }  
    </script>

    <!-- END    Select带可输入的功能  END-->
    <!-- BEGIN  画面的控制  BEGIN -->

    <script type='text/javascript'>
        $(document).ready(function() {


            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////
            //初始化数据
            GetDataSumirise("SELECT");
            //初始化权限
            SetInitialRights();
            //$("#txtDate").simpleDatepicker({ startdate: 1965, enddate: 2050 });
            /////////////////////////////////////////////////画面初始化//////////////////////////////////////////////

            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////
            //权限设定
            function SetInitialRights() {
                //汇总权限
                if ($('#hddRights').val() != "1") {
                    $("#btnSummarys").css({ "display": "none" });

                }
                //查看其它单位权限
                if ($('#hddOpen').val() != "1") {
                    $("#btnOpen").css({ "display": "none" });

                }
            }
            //追加行常量
            function SetRowValue(strValue1, strValue2, strValue3, strValue4, strValue5, strValue6, strValue7, strValue8, strValue9) {
                var strRowAdd = "<tr><td align='center' style='display:none'>a1</td><td align='center'>a2</td><td align='center'>a3</td><td align='center'>a4</td><td align='center'>a5</td><td align='center'>a6</td><td align='center'>a7</td><td align='center'>a8</td><td align='center'>a9</td></tr>";
                return strRowAdd.replace("a1", strValue1).replace("a2", strValue2).replace("a3", strValue3).replace("a4", strValue4).replace("a5", strValue5).replace("a6", strValue6).replace("a7", strValue7).replace("a8", strValue8).replace("a9", strValue9);
            }



            //追加行常量
            function SetRowValueBottom(strValue1, strValue2, strValue3, strValue4, strValue5) {
                var strRowAdd = "<tr><td align='center' style='display:none'>a1</td><td align='center'>a2</td><td align='center'>a3</td><td align='center'>a4</td><td align='center'>a5</td></tr>";
                return strRowAdd.replace("a1", strValue1).replace("a2", strValue2).replace("a3", strValue3).replace("a4", strValue4).replace("a5", strValue5);
            }



            //追加行数据
            function SetAddRowDataValue(RowNo, style) {
                if (style == "0") {
                    return SetRowValue(RowNo,   //a1  
                                        SetInputDefaultValue("", 5), //姓名
                                        SetInputDefaultValue("", 20), //个人将项
                                        SetDisEditSelectValue(GetSexList()), //性别
                                        SetInputDefaultValue("", 10), //出生年月
                                        SetInputDefaultValue("", 10), //获奖时间
                                        SetDisEditSelectValue(GetClassList("101")), //文化程度
                                        SetDisEditSelectValue(GetClassList("102")), //政治面貌
                                        SetInputDefaultValue("", 20), //岗位及职务
                                        "",
                                        "",
                                        ""
                                    )

                }
                else {

                    return SetRowValueBottom(RowNo,   //a1  
                                            SetInputDefaultValue("", 30),          //集体奖项		
                                            SetInputDefaultValue("", 30),           //单位名称
                                            SetInputDefaultValue("", 10),      //获奖时间
                                            SetInputDefaultValue("", 30)      //获奖时间
                     )

                }

            }


            //对应业务信息
            function GetDataSumirise(RightsFlg) {
                $('#lblCurrentYear').text($('#hddCurrentYear').val())
                //清空明细显示
                $("#example>tbody>tr").each(function(i, item) {
                    if (i > 0) {
                        $(this).remove();
                    }
                });

                $("#tabbottom>tbody>tr").each(function(i, item) {
                    if (i > 0) {
                        $(this).remove();
                    }
                });
                //明细赋值
                var strStrHtml = "";
                var strStrHtml1 = "";
                var queryString = "time=" + new Date() + "&TransFlg=ModelWorker1" + "&RightsFlg=" + RightsFlg + "&SelectYear=" + $('#hddCurrentYear').val();
                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../ajaxGetJason.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: queryString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            var temp = eval(data);
                            if (temp) {
                                $.each(temp, function(i, item) {
                                    var strTr = "<tr style='height: 22px;'><td align='center' style='display:none'>" + (i + 1)
                                              + "</td><td align='center'>" + item["姓名"]
                                              + "</td><td align='center'>" + item["个人奖项"]
                                              + "</td><td align='center'>" + item["性别名称"]
                                              + "</td><td align='center'>" + item["出生年月"]
                                              + "</td><td align='center'>" + item["获奖时间"]
                                              + "</td><td align='center'>" + item["文化程度名称"]
                                              + "</td><td align='center'>" + item["政治面貌名称"]
                                              + "</td><td align='center'>" + item["岗位及职务"]
                                              + "</td><td align='center'style='display:none'>" + item["性别"]
                                              + "</td><td align='center'style='display:none'>" + item["文化程度"]
                                              + "</td><td align='center'style='display:none'>" + item["政治面貌"]
                                              + "</td><td align='center'style='display:none'>" + item["No"]
                                              + "</td></tr> "
                                    strStrHtml += strTr;
                                });
                                $("#example").append(strStrHtml);
                            }
                        }
                    });


                queryString = "time=" + new Date() + "&TransFlg=ModelWorker2" + "&RightsFlg=" + RightsFlg + "&SelectYear=" + $('#hddCurrentYear').val();
                $.ajax
                    ({
                        async: false,
                        type: "post", //ajax请求方式
                        url: "../ajaxGetJason.aspx", //请求服务器地址
                        datatype: "json", //希望数据库返回的数据类型
                        data: queryString, //发送给服务器的数据
                        processData: false, //阻止数据被自动转换为url编码
                        success: function(data) {//请求成功则调用该函数
                            var temp = eval(data);
                            if (temp) {
                                $.each(temp, function(i, item) {
                                    var strTr = "<tr style='height: 22px;'><td align='center' style='display:none'>" + (i + 1)
                                              + "</td><td align='center'>" + item["集体奖项"]
                                              + "</td><td align='center'>" + item["单位名称"]
                                              + "</td><td align='center'>" + item["j集体获奖时间"]
                                              + "</td><td align='center' style='display:none'>" + item["No"]
                                              + "</td><td align='left'>" + item["备注"]
                                              + "</td></tr> "
                                    strStrHtml1 += strTr;
                                });
                                $("#tabbottom").append(strStrHtml1);
                            }
                            else {
                                $("#example").append(SetAddRowDataValue(1, '0'));
                                //追加Select Change事件
                                AddRowEvent(1);



                                $("#tabbottom").append(SetAddRowDataValue(1, '1'));
                                AddRowEventBottom(1);
                            }
                        }
                    });
            }
            function AddRowEvent(intRowNo) {
                //出生年月
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(4)").find('input').simpleDatepicker({ startdate: 1920, enddate: 2050 });
                //获奖时间 
                $("#example>tbody>tr:eq(" + intRowNo + ")").find("td:eq(5)").find('input').simpleDatepicker({ startdate: 1965, enddate: 2050 });
            }


            function AddRowEventBottom(intRowNo) {

                //获奖时间
                $("#tabbottom>tbody>tr:eq(" + intRowNo + ")").find("td:eq(3)").find('input').simpleDatepicker({ startdate: 1965, enddate: 2050 });
            }
            /////////////////////////////////////////////////画面共通方法//////////////////////////////////////////////


            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////
            //追加鼠标事件 行选择
            $('tbody > tr', $('#example')).live("click", function() {
                $('.selected').removeClass('selected');
                $(this).addClass('selected'); //this 表示引发事件的对象，但它不是 jquery 对象
                var tr_id = "1" + $(this).find("td:eq(0)").text();
                //对隐藏控件设定当前行的值
                $('#txtRowNo').val(tr_id);
            }).hover(		//注意这里的链式调用
					        function() {
					            $(this).addClass('mouseOver');
					        },
			        function() {
			            $(this).removeClass('mouseOver');
			        }
           );


            $('tbody > tr', $('#tabbottom')).live("click", function() {
                $('.selected').removeClass('selected');
                $(this).addClass('selected'); //this 表示引发事件的对象，但它不是 jquery 对象
                var tr_id = "2" + $(this).find("td:eq(0)").text();
                //对隐藏控件设定当前行的值
                $('#txtRowNo').val(tr_id);
            }).hover(		//注意这里的链式调用
	                    function() {
	                        $(this).addClass('mouseOver');
	                    },
                function() {
                    $(this).removeClass('mouseOver');
                }
            );



            //行删除
            $('#btnDelete').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                if (!window.confirm("请确认是否删除记录。 ")) {
                    return;
                }
                var rows = $('#txtRowNo').val();
                if (rows.substring(0, 1) == "1" || rows.substring(0, 1) == "") {
                    realRow = rows.substring(1, 2);
                    var no = $("#example").find("tr:eq(" + realRow + ")").find('td:eq(12)').text();

                    var queryString = "ID=" + no
                                        + "&FormFlg=" + "ModelWorker";
                    $.ajax
                                        ({
                                            async: false,
                                            type: "post", //ajax请求方式
                                            url: "../AjaxDelete.aspx", //请求服务器地址
                                            datatype: "json", //希望数据库返回的数据类型
                                            data: queryString, //发送给服务器的数据
                                            processData: false, //阻止数据被自动转换为url编码
                                            success: function(data) {//请求成功则调用该函数
                                                if (data == "OK") {
                                                    alert("删除成功！")
                                                    $("#example").find("tr:eq(" + realRow + ")").remove();
                                                }
                                                else {
                                                    alert("删除失败！")
                                                }
                                            }
                                        });
                }
                else {
                    realRow = rows.substring(1, 2);
                    var no = $("#tabbottom").find("tr:eq(" + realRow + ")").find('td:eq(4)').text();
                    var queryString = "ID=" + no
                                        + "&FormFlg=" + "ModelWorker1";
                    $.ajax
                                        ({
                                            async: false,
                                            type: "post", //ajax请求方式
                                            url: "../AjaxDelete.aspx", //请求服务器地址
                                            datatype: "json", //希望数据库返回的数据类型
                                            data: queryString, //发送给服务器的数据
                                            processData: false, //阻止数据被自动转换为url编码
                                            success: function(data) {//请求成功则调用该函数
                                                if (data == "OK") {
                                                    alert("删除成功！")
                                                    $("#tabbottom").find("tr:eq(" + realRow + ")").remove();
                                                }
                                                else {
                                                    alert("删除失败！")
                                                }
                                            }
                                        });
                }


            });

            //插入行
            $('#btnAdd').click(function() {
                var rows = $('#txtRowNo').val();
                //alert(rows.substring(0, 1));
                if (rows.substring(0, 1) == "1" || rows.substring(0, 1) == "") {
                    var tr_id = $("#example>tbody>tr:last").find("td:eq(0)").text();
                    if ($.trim(tr_id) == "序号" || $.trim(tr_id) == "") {
                        tr_id = 0;
                    }
                    var id = parseInt(tr_id) + 1;
                    $("#example").append(SetAddRowDataValue(id, '0'));
                    //追加Select Change事件
                    AddRowEvent(id);
                }
                else {
                    var tr_id = $("#tabbottom>tbody>tr:last").find("td:eq(0)").text();
                    if ($.trim(tr_id) == "序号" || $.trim(tr_id) == "") {
                        tr_id = 0;
                    }
                    var id = parseInt(tr_id) + 1;
                    $("#tabbottom").append(SetAddRowDataValue(id, '1'));
                    AddRowEventBottom(id);
                }

            });

            //行编辑
            $('#btnEdit').click(function() {
                if ($.trim($('#txtRowNo').val()) == "") {
                    alert("请选择行");
                    return;
                }
                var rows = $('#txtRowNo').val();


                if (rows.substring(0, 1) == "1" || rows.substring(0, 1) == "") {
                    realRow = rows.substring(1, 2);
                    if ($("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").find('input').length > 0) {
                        return;
                    }
                    //姓名
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").append(SetInputDefaultValue(editedContent4, 10));
                    //个人奖项
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").append(SetInputDefaultValue(editedContent4, 10));
                    //性别
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(9)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").append(SetDisEditSelectValue(GetSexList()));
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").find('select').val(editedContent4);
                    //出生年月
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(4)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(4)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(4)").append(SetInputDefaultValue(editedContent4, 10));

                    //获奖时间
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").append(SetInputDefaultValue(editedContent4, 10));


                    //文化程度
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(10)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(6)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(6)").append(SetDisEditSelectValue(GetClassList("101")));
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(6)").find('select').val(editedContent4);


                    //政治面貌
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(11)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(7)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(7)").append(SetDisEditSelectValue(GetClassList("102")));
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(7)").find('select').val(editedContent4);

                    //岗位及职务
                    editedContent4 = $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(8)").text();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(8)").empty();
                    $("#example>tbody>tr:eq(" + realRow + ")").find("td:eq(8)").append(SetInputDefaultValue(editedContent4, 10));


                    //追加Select Change事件
                    //AddRowEvent(id);
                }
                else {
                    realRow = rows.substring(1, 2);
                    if ($("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").find('input').length > 0) {
                        return;
                    }
                    //集体奖项
                    editedContent4 = $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").text();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").empty();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(1)").append(SetInputDefaultValue(editedContent4, 10));
                    //单位名称
                    editedContent4 = $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").text();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").empty();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(2)").append(SetInputDefaultValue(editedContent4, 10));
                    //获奖时间
                    editedContent4 = $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").text();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").empty();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(3)").append(SetInputDefaultValue(editedContent4, 10));



                    editedContent4 = $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").text();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").empty();
                    $("#tabbottom>tbody>tr:eq(" + realRow + ")").find("td:eq(5)").append(SetInputDefaultValue(editedContent4, 10));
                }



            });
            var blnCheckProgressLoop = true;
            /// <summary>
            /// <p><b>方法名：</b>CreateUpdateString</p>
            /// <p><b>概要説明:</b>ajax向后台传的参数，区分ID和子区分ID</p>
            /// <p><b>作者  :</b>程明亮</p>
            /// <p><b>日期  :</b>2009/07/24</p>
            /// <p><b>修正履历:</b></p>
            /// </summary>
            function CreateUpdateString() {
                blnCheckProgressLoop = true;
                var a1 = "";
                var a2 = "";
                var a3 = "";
                var a4 = "";
                var a5 = "";
                var a6 = "";
                var a7 = "";
                var a8 = "";
                var b1 = "";
                var b2 = "";
                var b3 = "";
                var b4 = "";
                $("#example").find("tr:not(:eq(0))").each(function() {
                    if (blnCheckProgressLoop == false) {
                        return;
                    }
                    //姓名
                    if ($(this).find('td:eq(1)').find('input').length > 0) {
                        a1 = a1 + $(this).find('td:eq(1)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(1)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(1)').find('input').focus();
                            $(this).find('td:eq(1)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        a1 = a1 + $(this).find('td:eq(1)').text() + ",";
                    }
                    //个人奖项
                    if ($(this).find('td:eq(2)').find('input').length > 0) {
                        a2 = a2 + $(this).find('td:eq(2)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(2)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(2)').find('input').focus();
                            $(this).find('td:eq(2)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        a2 = a2 + $(this).find('td:eq(2)').text() + ",";
                    }
                    //性别
                    if ($(this).find('td:eq(3)').find('select').length > 0) {
                        a3 = a3 + $(this).find('td:eq(3)').find('select').val() + ",";
                    }
                    else {
                        a3 = a3 + $(this).find('td:eq(9)').text() + ",";
                    }
                    //出生年月
                    if ($(this).find('td:eq(4)').find('input').length > 0) {
                        a4 = a4 + $(this).find('td:eq(4)').find('input').val() + ",";
                    }
                    else {
                        a4 = a4 + $(this).find('td:eq(4)').text() + ",";
                    }
                    //获奖时间
                    if ($(this).find('td:eq(5)').find('input').length > 0) {
                        a5 = a5 + $(this).find('td:eq(5)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(5)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(5)').find('input').focus();
                            $(this).find('td:eq(5)').find('input').select();
                            return false;
                        }
                        if (!IsDate($.trim($(this).find('td:eq(5)').find('input').val()))) {
                            blnCheckProgressLoop = false;
                            alert("对不起,您输入的日期格式不正确!");
                            $(this).find('td:eq(5)').find('input').focus();
                            $(this).find('td:eq(5)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        a5 = a5 + $(this).find('td:eq(5)').text() + ",";
                    }
                    //文化程度
                    if ($(this).find('td:eq(6)').find('select').length > 0) {
                        a6 = a6 + $(this).find('td:eq(6)').find('select').val() + ",";
                    }
                    else {
                        a6 = a6 + $(this).find('td:eq(10)').text() + ",";
                    }
                    //政治面貌
                    if ($(this).find('td:eq(7)').find('select').length > 0) {
                        a7 = a7 + $(this).find('td:eq(7)').find('select').val() + ",";
                    }
                    else {
                        a7 = a7 + $(this).find('td:eq(11)').text() + ",";
                    }
                    //岗位及职务
                    if ($(this).find('td:eq(8)').find('input').length > 0) {
                        a8 = a8 + $(this).find('td:eq(8)').find('input').val() + ",";
                    }
                    else {
                        a8 = a8 + $(this).find('td:eq(8)').text() + ",";
                    }
                });


                $("#tabbottom").find("tr:not(:eq(0))").each(function() {
                    if (blnCheckProgressLoop == false) {
                        return;
                    }
                    //集体奖项 
                    if ($(this).find('td:eq(1)').find('input').length > 0) {
                        b1 = b1 + $(this).find('td:eq(1)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(1)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(1)').find('input').focus();
                            $(this).find('td:eq(1)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        b1 = b1 + $(this).find('td:eq(1)').text() + ",";
                    }
                    //单位名称 
                    if ($(this).find('td:eq(2)').find('input').length > 0) {
                        b2 = b2 + $(this).find('td:eq(2)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(2)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(2)').find('input').focus();
                            $(this).find('td:eq(2)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        b2 = b2 + $(this).find('td:eq(2)').text() + ",";
                    }
                    //获奖时间 
                    if ($(this).find('td:eq(3)').find('input').length > 0) {
                        b3 = b3 + $(this).find('td:eq(3)').find('input').val() + ",";
                        if ($.trim($(this).find('td:eq(3)').find('input').val()) == "") {
                            blnCheckProgressLoop = false;
                            alert("不可以省略!");
                            $(this).find('td:eq(3)').find('input').focus();
                            $(this).find('td:eq(3)').find('input').select();
                            return false;
                        }
                        if (!IsDate($.trim($(this).find('td:eq(3)').find('input').val()))) {
                            blnCheckProgressLoop = false;
                            alert("对不起,您输入的日期格式不正确!");
                            $(this).find('td:eq(3)').find('input').focus();
                            $(this).find('td:eq(3)').find('input').select();
                            return false;
                        }
                    }
                    else {
                        b3 = b3 + $(this).find('td:eq(3)').text() + ",";
                    }

                    if ($(this).find('td:eq(5)').find('input').length > 0) {
                        b4 = b4 + $(this).find('td:eq(5)').find('input').val() + ",";
                    }
                    else {
                        b4 = b4 + $(this).find('td:eq(5)').text() + ",";
                    }
                });

                var queryString = "a1=" + a1
                               + "&a2=" + a2
                               + "&a3=" + a3
                               + "&a4=" + a4
                               + "&a5=" + a5
                               + "&a6=" + a6
                               + "&a7=" + a7
                               + "&a8=" + a8
                               + "&b1=" + b1
                               + "&b2=" + b2
                               + "&b3=" + b3
                               + "&b4=" + b4
                               + "&UpdateFlg=" + "Update"
                               + "&UpdateFlg=" + "Update"
                               + "&CurrentYear=" + $('#hddCurrentYear').val()
                               + "&FormFlg=" + "ModelWorker";
                return queryString;
            };

            //提交画面所有数据
            $('#btnSave').click(function() {
                if ($("#example").find("tr").length == 1 && $("#tabbottom").find("tr").length == 1) {
                    alert("没有可保存的数据！");
                    return;
                }
                //全部验证
                CreateUpdateString();
                if (!blnCheckProgressLoop) {
                    return;
                }

                $.ajax
            ({
                async: false,
                type: "post", //ajax请求方式
                url: "../ajaxUpdate.aspx", //请求服务器地址
                datatype: "json", //希望数据库返回的数据类型
                data: CreateUpdateString(), //发送给服务器的数据
                processData: false, //阻止数据被自动转换为url编码
                success: function(data) {//请求成功则调用该函数
                    if (data == "OK") {
                        alert("更新成功！")
                        GetDataSumirise("SELECT");
                        //var submitForm = document.getElementById("mainForm");
                        //submitForm.submit();
                    }
                    else {
                        alert("更新失败！")
                    }
                }
            });

            });

            //单位选择画面
            $('#btnOpenUnion').click(function() {
                $("#datepanle").dialog('open');
            });
            $("#datepanle").dialog({
                bgiframe: true,
                autoOpen: false,
                height: 150,
                modal: true,
                draggable: true,
                buttons: {
                    '提交': function() {
                        $('#lblCurrentYear').text($('#txtDate').val())
                        $('#hddCurrentYear').val($('#txtDate').val())
                        GetDataSumirise("SELECT");
                        $(this).dialog('close');
                    },
                    '取消': function() {
                        $(this).dialog('close');
                    }
                },
                close: function() {
                    $("#txtDate").val("");
                }
            });
            //选择日期
            $('#btnOpenYear').click(function() {
                $('#lblCurrentYear').text($('#hddCurrentYear').val())
                window.showModalDialog("../Common/SelectYear.aspx?Random=" + Math.random() + "&FromFlg=ModelWorker", window, "dialogWidth:173px;dialogHeight:400px;status=no;help=no;scroll:no");
                var submitForm = document.getElementById("mainForm");
                submitForm.submit();
                //清空当前行号
                $('#txtRowNo').val("");
                $('#hddSumarry').val("0");
            });
            //汇总
            $('#btnSummarys').click(function() {
                GetOrganizationSumirise("Summary");
                //汇总区分
                $('#hddSumarry').val("1");
            });


            //打印
            $('#btnPrintView').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可打印的数据！");
                    return;
                }
                openwindow("ModelWorkerPrint.aspx?Random=" + Math.random() + " &RightsFlg=" + "Summary", 'newwindow', 950, 500);

            });

            $('#btnExcelExport').click(function() {
                if ($("#example").find("tr").length == 1) {
                    alert("没有可导出的数据！");
                    return;
                }
                window.open("../Common/ExcelExport.aspx?Random=" + Math.random() + "&TransFlg=ModelWorker" + "&theDate=" + $("#hddCurrentYear").val(), "win");
            });


            /////////////////////////////////////////////////画面事件//////////////////////////////////////////////


        });
	
    </script>

    <!-- END    画面的控制  END   -->
</head>
<body>
    <form id="mainForm" runat="server">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="100%" cellpadding="0" cellspacing="0" class="table" border="0px">
                    <tr>
                        <td valign="top">
                            <table width="100%" class="top" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td style="height: 22px;">
                                        &nbsp;<b>当前位置:</b>&nbsp;<a href="#">工会管理</a>&nbsp;>>&nbsp;<a href="#">劳动模范及获乐山市以上先进集体统计表</a><input
                                            id="txtRowNo" type="text" style="display: none" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td align="right" valign="middle" style="border: thin dotted #C0C0C0; background-color: #C5E5FC">
                            <img alt="" id="btnOpenUnion" src="../images/button/btnOpenAdd.gif" />
                            &nbsp;
                            <img alt="" id="btnOpenYear" src="../images/button/btnOpen.gif" />
                            &nbsp;
                            <img alt="" id="btnSave" src="../images/button/btnSave.gif" />
                            &nbsp;
                            <img alt="" id="btnPrintView" src="../images/button/btnPrint.gif" />
                            &nbsp;
                            <img alt="" id="btnAdd" src="../images/button/btnInsertRow.gif" />
                            &nbsp;
                            <img alt="" id="btnDelete" src="../images/button/btnDeleteRow.gif" />
                            &nbsp;
                            <img alt="" id="btnEdit" src="../images/button/btnEditRow.gif" />
                            &nbsp;
                            <img alt="" id="btnExcelExport" src="../images/button/btnExcelExport.gif" />
                            <%--    &nbsp;
                            <img alt="" id="btnSummarys" src="../images/button/btnSummary.gif" /> --%>
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 5px">
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 30px" align="center" class="style1">
                            <asp:Label ID="lblCurrentYear" runat="server" Text=""></asp:Label>劳动模范情况统计表
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" style="height: 130px;" align="left">
                            <table id='example' style="width: 100%;" cellpadding='0px' cellspacing='0px'>
                                <!--<thead style="text-align:center;" >-->
                                <tr>
                                    <!--a1-->
                                    <th style="width: 30px; height: 22px; background-color: #B2DBF7; display: none" align="center">
                                        序号
                                    </th>
                                    <th style="width: 100px; height: 22px; background-color: #B2DBF7;" align="center">
                                        姓名
                                    </th>
                                    <th style="width: 300px; height: 22px; background-color: #B2DBF7;" align="center">
                                        个人奖项
                                    </th>
                                    <th style="width: 60px; height: 22px; background-color: #B2DBF7;" align="center">
                                        性别
                                    </th>
                                    <th style="width: 100px; height: 22px; background-color: #B2DBF7;" align="center">
                                        出生年月
                                    </th>
                                    <th style="width: 100px; height: 22px; background-color: #B2DBF7;" align="center">
                                        获奖时间
                                    </th>
                                    <th style="width: 140px; height: 22px; background-color: #B2DBF7;" align="center">
                                        文化程度
                                    </th>
                                    <th style="width: 120px; height: 22px; background-color: #B2DBF7;" align="center">
                                        政治面貌
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7;" align="center">
                                        岗位及职务
                                    </th>
                                    <th style="width: 30px; height: 22px; background-color: #B2DBF7; display: none" align="center">
                                    </th>
                                    <th style="width: 30px; height: 22px; background-color: #B2DBF7; display: none" align="center">
                                    </th>
                                    <th style="width: 30px; height: 22px; background-color: #B2DBF7; display: none" align="center">
                                    </th>
                                </tr>
                                <!--</thead>-->
                                <!--<tbody id='content'>-->
                                <!--</tbody>-->
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <table id='tabbottom' style="width: 100%; border-collapse: collapse;">
                                <!--<thead style="text-align:center;" >-->
                                <tr>
                                    <!--a1-->
                                    <th style="width: 30px; height: 22px; background-color: #B2DBF7; display: none" align="center">
                                        序号
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7;" align="center">
                                        集体奖项
                                    </th>
                                    <th style="width: 300px; height: 22px; background-color: #B2DBF7;">
                                        单位名称
                                    </th>
                                    <th style="width: 100px; height: 22px; background-color: #B2DBF7;" align="center">
                                        获奖时间
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7; display: none" align="center">
                                    </th>
                                    <th style="height: 22px; background-color: #B2DBF7;" align="center">
                                        备注
                                    </th>
                                </tr>
                                <!--</thead>-->
                                <!--<tbody id='content'>-->
                                <!--</tbody>-->
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="hddRights" runat="server" />
    <asp:HiddenField ID="hddSumarry" runat="server" />
    <asp:HiddenField ID="hddOpen" runat="server" />
    <asp:HiddenField ID="hddCurrentYear" runat="server" />
    <div id="datepanle" title="选择年份">
        <fieldset>
            <div style="text-align: center; vertical-align: middle">
                <input id="txtDate" type="text" maxlength="4" />年</div>
        </fieldset>
    </div>

    <script type="text/javascript">
        $("#datepanle").hide();
    </script>

    </form>
</body>
</html>
